#ifndef HTTPMGR_H
#define HTTPMGR_H

#include<QUrl>
#include "singleton.h"
#include"global.h"

//创建单例网络类
class HttpMgr : public QObject, public Singleton<HttpMgr>
    ,public std::enable_shared_from_this<HttpMgr>//用来实现伪闭包
{
    Q_OBJECT
public:
    ~HttpMgr();
    void PostHttpReq(QUrl &&url, QByteArray &&data, ReqID id, Modules mod);

private:
    friend class Singleton<HttpMgr>;
    HttpMgr();

private slots:
    void HttpFinish(ReqID id, QByteArray res, Modules mod, ErrorCodes err = ErrorCodes::StatusOK);

signals:
    void sig_http_finish(ReqID id, QString res, Modules mod, ErrorCodes err = ErrorCodes::StatusOK);//需要吗？
    void sig_reg_login_mod_finish(QByteArray, ReqID, ErrorCodes);
    void sig_find_mod_finish(QByteArray, ReqID, ErrorCodes);
private:
    QNetworkAccessManager manager;
};

#endif // HTTPMGR_H
